package cn.itcast.web;

import cn.itcast.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.List;

/**
 * @author 虎哥
 */
@Controller
public class HelloController {

    @GetMapping("hello")
    public String hello(Model model) {
        model.addAttribute("msg", "hello, thymeleaf");

        User user = new User("Jack", 21);
        model.addAttribute("user", user);

        List<User> list = Arrays.asList(new User("LiuDeHua", 21),
                new User("HuGe", 21),
                new User("zhanghuyi", 18),
                new User("pengyuyan", 21)
        );
        model.addAttribute("users", list);
        return "hello";
    }
}
